<?php

// $Id$


require_once(TANGRA_MAIN_DIR.'interfaces/i_db_storable.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/tcms_registry_keys.class.php');
require_once($WSC->get_site_inc_dir().'modules/registry_db/registry_key_db.class.php');


class TCMS_Settings_Content_DBC extends Tangra_Class implements I_DB_Storable {
	private $id;
	private $max_text_size;
	private $max_total_size;

	//fake
	public function set_id($id) {
	}


	//fake
	public function get_id() {
		return 1;
	}


	public function save(DB_Connection $dbc) {
		$this->max_text_size->save($dbc);
		$this->max_total_size->save($dbc);

		return 1;
	}


	public function load_by_id(DB_Connection $dbc, $id) {
		tangra_if_not_int_throw_e($id);


		$max_text_size_id = Registry_Key_DB::key_exists($dbc, TCMS_Registry_Keys::KEY_TCMS_CONTENT_MAX_TEXT_SIZE);
		if ($max_text_size_id) {
			$max_text_size = new Registry_Key_DB();
			$max_text_size->load_by_id($dbc, $max_text_size_id);
			$this->max_text_size = $max_text_size;
		} else {
			throw new Tangra_Module_Exception('Registry key missing: '.TCMS_Registry_Keys::KEY_TCMS_CONTENT_MAX_TEXT_SIZE);
		}


		$max_total_size_id = Registry_Key_DB::key_exists($dbc, TCMS_Registry_Keys::KEY_TCMS_CONTENT_MAX_TOTAL_SIZE);
		if ($max_total_size_id) {
			$max_total_size = new Registry_Key_DB();
			$max_total_size->load_by_id($dbc, $max_total_size_id);
			$this->max_total_size = $max_total_size;
		} else {
			throw new Tangra_Module_Exception('Registry key missing: '.TCMS_Registry_Keys::KEY_TCMS_CONTENT_MAX_TOTAL_SIZE);
		}

		return 1;
	}


	public function set_max_text_size($value) {
		$this->max_text_size->set_value($value);
	}


	public function get_max_text_size() {
		return $this->max_text_size->get_value();
	}


	public function set_max_total_size($value) {
		$this->max_total_size->set_value($value);
	}


	public function get_max_total_size() {
		return $this->max_total_size->get_value();
	}

}